package com.springboot.repository;

import com.springboot.domain.BtUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface UserRepository extends JpaRepository<BtUser, String>{
    BtUser findByUserId (String userId);

    BtUser findByUserName(String name);

    @Query("select bu from BtUser bu where bu.status='0' and bu.userType in ('person','enterprise')")
    List<BtUser> findByUserType();

    @Query("select bu from BtUser bu where bu.status='0' and bu.userType in ('person','enterprise') and bu.userId  not in ?1")
    List<BtUser> findUserNotInProject(List<String> usersId);

    @Query("select bu from BtUser bu where bu.status='0' and bu.userType in ('person') and bu.userName like concat('%',?1,'%')")
    List<BtUser> findByFuzzyQuery(String name);
}
